package com.tuanzi.loan.web.bean.family;

import javax.annotation.PostConstruct;
import javax.faces.bean.ViewScoped;

import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.math.NumberUtils;
import org.primefaces.component.tabview.TabView;
import org.primefaces.event.TabChangeEvent;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import com.tuanzi.loan.business.service.family.LoanApiOrderService;
import com.tuanzi.loan.core.aspect.Debug;
import com.tuanzi.loan.vo.view.family.LoanApiOrderInfoView;
import com.tuanzi.loan.web.configuration.JSFInfoBean;

import lombok.Data;
import lombok.EqualsAndHashCode;

/**
 * 查询订单详情
 * @author 2018/01/12
 *
 */
@Data
@Debug
@Component
@ViewScoped
@EqualsAndHashCode(callSuper = true)
public class LoanApiOrderInfoBean extends JSFInfoBean<LoanApiOrderInfoView> {

	private static final long serialVersionUID = -4380533399489691242L;
	
	@Autowired
	private LoanApiOrderService loanApiOrderService;
	private Integer activeTabIndex;

	@PostConstruct
	private void init() {
		String id = getParamFromRequest("id");
		if (StringUtils.isNotBlank(id)) {
			$ = loanApiOrderService.loanApiOrderInfoView(NumberUtils.toLong(id));
		}
		activeTabIndex = 0;
	}

	public void onChangeTabView(TabChangeEvent event) {
		TabView tv = (TabView) event.getComponent();
		this.activeTabIndex = tv.getActiveIndex();
	}
}
